import request from '@/utils/request'

/**
 * @description 获取所有角色列表
 * @param {Object} params {page,pagesize}
 * @returns Promise
 */
export function getAllRoleAPI(params) {
    return request({
        url: '/sys/role',
        method: 'GET',
        params
    })
}

/**
 * @description 获取角色详情信息
 * @param {String} id 
 * @returns Promise
 */
export function getRoleDetailsAPI(id) {
    return request({
        url: `/sys/role/${id}`,
        method: 'GET'
    })
}

/**
 * @description 删除角色
 * @param {String} id 
 * @returns Promise
 */
export function deleteRoleAPI(id) {
    return request({
        url: `/sys/role/${id}`,
        method: 'DELETE'
    })
}
/**
 * @description 更新角色
 * @param {Object} data 
 * @returns Promise
 */
export function updateRoleAPI(data) {
    return request({
        url: `/sys/role/${data.id}`,
        method: 'PUT',
        data
    })
}

/**
 * @description 新增角色
 * @param {Object} data 
 * @returns Promise
 */
export function createRoleAPI(data) {
    return request({
        url: '/sys/role',
        method: 'POST',
        data
    })
}

/**
 * @description 分配角色权限
 * @param {Object} data 
 * @returns Promise
 */
export function assignPermissionsAPI(data) {
    return request({
        url: '/sys/role/assignPrem',
        method: 'PUT',
        data
    })
}
